package com.zhubg.bingo.admin.security;

import com.zhubg.bingo.admin.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;

import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author bingo
 * @title: JwtAuthenticationFilter
 * @projectName bingo-pom
 * @description: TODO 登录认证过滤器
 * @date 2019-09-28-18:41
 */
public class JwtAuthenticationFilter extends BasicAuthenticationFilter {


    @Autowired
    public JwtAuthenticationFilter(AuthenticationManager authenticationManager) {
        super(authenticationManager);
    }

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain){

        try {
            SecurityUtils.checkAuthentication(request);
            chain.doFilter(request,response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
